package pkg

import (
	goredislib "github.com/redis/go-redis/v9"
)

type RedisConfig struct {
	Addr     string `yaml:"addr" mapstructure:"addr"`
	Password string `yaml:"password" mapstructure:"password"`
}

func RedisInit(redisConfig RedisConfig) (*goredislib.Client, error) {
	// Create a pool with go-redis (or redigo) which is the pool redisync will
	// use while communicating with Redis. This can also be any pool that
	// implements the `redis.Pool` interface.
	// 创建redis 客户端
	client := goredislib.NewClient(&goredislib.Options{
		Addr:     redisConfig.Addr,
		Password: redisConfig.Password,
	})
	return client, nil
}
